#ifndef _OCPP_GribTime_H__
#define _OCPP_GribTime_H__

#include "GribDefine.h"
#include "OCMain/Date.h"

namespace OCPP
{
	class GribTime
	{
	public:
		GribTime();
		GribTime(time_t t1, time_t t2);
		~GribTime();

		using TimeBound = std::tuple<time_t, time_t>;
		TimeBound _timeBound;

		bool operator < (const GribTime& lhs) const
		{
			auto [t1, t2] = _timeBound;
			auto [t11, t22] = lhs._timeBound;

			if (t1 == t11)
			{
				return t2 < t22;
			}

			return t1 < t11;
		}

		bool operator == (const GribTime& lhs) const
		{
			return std::get<0>(_timeBound) == std::get<0>(lhs._timeBound)
				&& std::get<1>(_timeBound) == std::get<1>(lhs._timeBound);
		}

		const String toString() const
		{
			auto [t1, t2] = _timeBound;
			auto t1Str = Date(t1 * MICRO_SECONDS_PRE_SEC).toCustomedFormattedString("%Y%m%d%H%M%S", false);
			if (t1 == t2)
			{
				return t1Str;
			}
			auto t2Str = Date(t2 * MICRO_SECONDS_PRE_SEC).toCustomedFormattedString("%Y%m%d%H%M%S", false);
			return t1Str + "_" + t2Str;
		}
	};

	using GribTimeVec = std::vector<GribTime>;
}


#endif // !_OCPP_GribReader_H__
